package main

import (
	"common/config"
	"common/initialize"
	"common/pkg"
	grpc2 "google.golang.org/grpc"
	"log"
	"user_server/grpc"
	"user_server/service"
)

func main() {
	config.InitViper()
	initialize.InitNachos(func() {
		initialize.InitMysql()
		initialize.InitRedis()
		initialize.InitEs()
		initialize.InitMonGoDb()
	})
	initialize.InitMysql()
	initialize.InitRedis()
	initialize.InitEs()
	initialize.InitLog()
	initialize.InitMonGoDb()
	//grpc.RegisterUserGrpc("127.0.0.1", 9991, func(server *grpc2.Server) {
	//	service.UserRegister(server)
	//})
	//pkg.Chat()
	// 使用 goroutine 启动 gRPC 服务
	go func() {
		grpc.RegisterUserGrpc("127.0.0.1", 9991, func(server *grpc2.Server) {
			service.UserRegister(server)
		})
		log.Println("gRPC server started at :9991")

		// 保持 gRPC 服务运行
		select {} // 或者使用 gRPC 的阻塞调用
	}()

	// 启动 HTTP 服务
	pkg.Chat()
}
